package com.config;

import com.filter.FirstFilter;
import com.filter.MyFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Arrays;

@Configuration
public class MyFilterConfiguration {
    @Bean
    public FilterRegistrationBean<FirstFilter> registration(FirstFilter filter){
        FilterRegistrationBean<FirstFilter> registrationBean = new FilterRegistrationBean<>(filter);
//        设置为true才注册
        registrationBean.setEnabled(true);
        registrationBean.setOrder(-1);
        registrationBean.setUrlPatterns(Arrays.asList("/*"));
        return registrationBean;
    }

    @Bean
    public FilterRegistrationBean<MyFilter> registration2(MyFilter filter){
        FilterRegistrationBean<MyFilter> registrationBean = new FilterRegistrationBean<>(filter);
//        设置为true才注册
        registrationBean.setEnabled(true);
        registrationBean.setOrder(-2);
        registrationBean.setUrlPatterns(Arrays.asList("/*"));
        return registrationBean;
    }
}
